Helpful Information
 
 
Category: Perl
Perl -> mySQL: "Lost connection to MySQL server during query" - pl help!

Hi,

I realize many people may have faced this problem earlier. I have searched through online problems list (including two in this forum), but have been unsuccessful to find a solution to my problem; I would really appreciate if someone can help.

I am trying to connect from PERL to a mySQL database.

My Perl script has the following:
"...
.
.

use DBI;
$user="root";
$password="";
$dsn = "dbi:mysql:dmtmp:ausdhcp92-128:3306";

#making a connection to the database
$db = DBI->connect($dsn, $user, $password) or die "Can't connect to the DB: $DBI::errstr\n";


.
..
..."

However, with this, I get the following message on my console when I try and run this script:

DBI->connect(dmtmp:ausdhcp92-128:3306) failed: Lost connection to MySQL server during query at dmtest.pl line 33
Can't connect to the DB: Lost connection to MySQL server during query

(my perl file's name is dmtest.pl)

I have tried many variations of my DB connect request, including the following:

1) $db = Mysql->connect($host, $database, $user, $password);

where
$host="ausdhcp92-128";
$database="dmtmp";

2) db = DBI->connect("DBI:mysql:host=$host:database=$database", $user, $password);

Those have not worked out either.

I'd really appreciate if someone can help.

Thanks.

The only thing I was able to find was a very long bugzilla thread regarding this problem under RedHat. Seems there is a bad glibc that causes this problem.

There were certain update fixes that needed careful following. If this is your case, check out this link: http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=76631

Seems the quickest temporary fix was to add the host name to your /ect/hosts file so that mysql doesn't try to use DNS to resolve the host name to ip. Otherwise it always works if the host name was 127.0.0.1.










privacy (GDPR)